<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="">
    <meta http-equiv="x-dns-prefetch-control" content="on">

    <title>首页</title>
    <link href="../css/css.css" rel="stylesheet" type="text/css">
    <script src="../js/jquery-v1.11.2.min.js"></script>
    <script src="../js/common.js"></script>
    <script src="../js/driver.js"></script>
</head>
<body>
<section class="slider_inner">
    <div class="slider_dot">
        <div class="dot_checked w_checked"></div>
        <div class="dot_none w_none"></div>
        <div class="dot_none w_none"></div>
        <div class="dot_none w_none"></div>
        <div class="dot_none w_none"></div>
    </div>
    <div class="slider_item"><img src="../img/banner.png"/></div>
</section>
<section class="pall15" style="overflow: hidden;">
    <div class="home_button mr4p" onclick="bid()">
        <label class="hometext">抢单</label>
        <i class="iconfont home_ico">&#xe70f;</i>
    </div>
    <div class="home_button" onclick="order()">
        <label class="hometext">我的订单</label>
        <i class="iconfont home_ico">&#xe710;</i>
    </div>
    <div class="home_button mr4p" id="workStatusDiv">
        <label class="hometext">开始接单</label>
        <i class="iconfont home_ico">&#xe712;</i>
    </div>
    <div class="home_button">
        <label class="hometext">交运客服</label>
        <label class="tel">65376537</label>
        <i class="iconfont home_ico">&#xe711;</i>
    </div>
</section>

<script type="text/javascript">
    $(function () {
        checkDriverTokenIndex();//token验证
        var driverInfo = eval("("+localStorage.getItem("driverInfo")+")");
        console.log("===="+JSON.stringify(driverInfo));
        genWorkStatus(driverInfo.lockFlag);
    });
    function bid() {
        window.location.href = "../driver/bid/bid_list.html";
    }
    function order() {
        window.location.href = "../driver/order/order_list.html";
    }
    function genWorkStatus(lockFlag){
    	var htmlStr="";
    	if(lockFlag=="0"){
    		$("#workStatusDiv").removeClass();
            $("#workStatusDiv").addClass("home_button_stop mr4p");
        	htmlStr='<label class="hometext" onclick="chgWorkStatus(1);">停止接单</label><i onclick="chgWorkStatus(1);" class="iconfont home_ico">&#xe719;</i>';
        }else{
        	$("#workStatusDiv").removeClass();
            $("#workStatusDiv").addClass("home_button mr4p");
        	htmlStr='<label class="hometext" onclick="chgWorkStatus(0);">开始接单</label><i onclick="chgWorkStatus(0);" class="iconfont home_ico">&#xe712;</i>';
        }
        $("#workStatusDiv").html(htmlStr);
    }
    function chgWorkStatus(lockFlag) {
    	var driverUuid=getCookie("driverUuid");
        $.ajax({
            type: 'POST',
            url: _global.serverHost + '/driver/chgLockFlag.htm',
            dataType: "json",
            data: { 'driverUuid': driverUuid,'lockFlag':lockFlag},
            success: function (data) {
                if (data.outResult == '1') {
                	console.log("===="+JSON.stringify(data));
                	genWorkStatus(data.lockFlag);
                } else {
                	alert(data.outResultReason);
                }
            }
        });
    }
</script>
</body>
</html>